let Mock=require("mockjs")
Mock.mock("/api/mock","get",function(config){
    console.log(config);
    return arr
})
let arr=[
    {
        "id":0,
        "name":"每日知识竞赛",
        "xiand":"每天5次，每次5题，每题3分",
        "startTime":"",
        "endTime":""
    },
    {
        "id":1,
        "name":"环保知识竞赛第一期",
        "xiand":"每天4次，每次10题，每题10分",
        "startTime":"",
        "endTime":""
    },
    {
        "id":2,
        "name":"计算机职业技能竞赛",
        "xiand":"每天1次，每次5题，每题10分",
        "startTime":"2021-08-28 00:00:00",
        "endTime":"2026-08-28 00:00:00"
    },
    {
        "id":3,
        "name":"学史明德学史增信学史崇德学史力行",
        "xiand":"每天1次，每次5题，每题20分",
        "startTime":"2021-11-01 00:00:00",
        "endTime":"2022-12-31 00:00:00"
    },
]
//删除
Mock.mock(/\/api\/examdelete\/\d/,"delete",function(config){
    console.log(config.url)
    let id=config.url.split("/")
    let index=id.pop()
    arr.splice(index,1)
    return arr

})
//增加
Mock.mock("/api/add","post",function(config){
    console.log("mock里面的数据",config)
    let body =JSON.parse(config.body)
    console.log(body)
    let name=body.name
    let xd=body.xd
    let startTime=body.startTime
    let endTime=body.endTime
    arr.push({id:arr.length,name,xd,startTime,endTime})
    return arr
})